package top.huhuiyu.springboot.study.validate;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author 胡辉煜
 * 通用分组校验
 */
public interface CommonValidator {

  // 邮箱正则
  String EMAIL = "^[\\w\\.-]+@([\\w\\-]+\\.)+[\\w\\-]{2,}$";

  String USERNAME = "^[a-zA-Z][a-zA-Z0-9_]{3,15}$";

  default boolean checkEmail(String email) {
    Pattern pattern = Pattern.compile(EMAIL);
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
  }

  /**
   * 添加分组
   */
  interface Add {
  }

  /**
   * 更新分组
   */
  interface Update {
  }

  /**
   * 删除分组
   */
  interface Delete {
  }
}
